package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xmy.cultivate.entity.TrainAuditTeacherSet;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 审核老师设置 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2025-07-01
 */
@Mapper
public interface TrainAuditTeacherSetMapper extends BaseMapper<TrainAuditTeacherSet> {


    @Select({ "<script>",
            "SELECT t1.*, t2.name AS auditName",
            "FROM train_audit_teacher_set AS t1",
            "LEFT JOIN staff AS t2 ON t1.teacher_id = t2.id",
            "WHERE 1=1",
            "<if test ='yearPart != null and yearPart !=&apos;&apos;'>",
            "AND t1.year_part = ${yearPart} ",
            "</if>",
            "<if test ='quarterNum != null and quarterNum !=&apos;&apos;'>",
            "AND t1.quarter_num = ${quarterNum} ",
            "</if>",
            "<if test ='name != null and name !=&apos;&apos;'>",
            "AND t2.name LIKE CONCAT('%',#{name},'%') ",
            "</if>",
            "<if test ='subType != null and subType !=&apos;&apos;'>",
            "AND t1.sub_type = ${subType} ",
            "</if>",
            "AND t1.department_id = ${departmentId} ",
            "AND t1.type = ${type} ",
            "ORDER BY t1.created_at DESC",
            "</script>"})
    public IPage<TrainAuditTeacherSet> findAll(IPage<TrainAuditTeacherSet> page, @Param("yearPart") String yearPart,
                                               @Param("quarterNum") String quarterNum,
                                               @Param("departmentId") Long departmentId,
                                               @Param("type") Integer type,
                                               @Param("name") String name,
                                               @Param("subType") Integer subType
                                               );

}
